package com.ruoyi.redis.sjtest;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Calendar;
import java.util.Date;

public class RedisUuid {
//    public long nextId (String keyPrefix) {
//    	// 生成时间戳
//    	// 生成序列号
//    	// 拼接并返回
//    	
//    	
//    	
//    }
    
    
    
    
    public static void test2() throws ParseException  {
    	   DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    	   java.util.Date date = df.parse("2022-01-01");
    	   Calendar cal = Calendar.getInstance();
    	   cal.setTime(date);
    	   long timestamp = cal.getTimeInMillis();
    	   System.out.println(timestamp);
    	   System.out.println(timestamp/1000);
    	}
    
    
    public static void main(String[] args) {
		LocalDateTime time = LocalDateTime.of(2022, 1,1,0,0,0);
    	long second = time.toEpochSecond(ZoneOffset.ofTotalSeconds(8*60*60)); //北京时间
    	// long second = time.toEpochSecond(ZoneOffset.UTC); utc 时间
    	// 1640995200
    	System.out.println(second);
     	long ss = System.currentTimeMillis();
    	System.out.println(ss);
    	long second2 = new Date().getTime();  	
    	System.out.println(second2);
    	
    	try {
			RedisUuid.test2();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
	}
    
    
    
}
